package org.zt.dao;

import java.util.LinkedList;

import javax.annotation.Resource;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.stereotype.Repository;
import org.zt.bean.DBNode;
import org.zt.bean.DBNodeData;
import org.zt.bean.FrameData;
import org.zt.mapper.NodeMapper;
@Repository
public class NodeDao implements INodeDao {
  @Resource
  private SqlSessionFactory sqlSessionFactory;
  
  public DBNode queryNode(){
	  SqlSession session=sqlSessionFactory.openSession();
	  NodeMapper mapper= session.getMapper(NodeMapper.class);
	   DBNode node= mapper.queryNode();
	   session.close();
	  return node;
  }

@Override
public int saveDBNode(DBNode dbNode) {
	// TODO Auto-generated method stub
	 SqlSession session=sqlSessionFactory.openSession();
	 NodeMapper mapper=session.getMapper(NodeMapper.class);
	 int isok=mapper.saveDBNode(dbNode);
	 session.close();
	return isok;
}

@Override
public int saveNodeData(DBNodeData nodeData) {
	// TODO Auto-generated method stub
	SqlSession session=sqlSessionFactory.openSession();
	 NodeMapper mapper=session.getMapper(NodeMapper.class);
	 int isok=mapper.saveNodeData(nodeData);
	 session.close();
	return 0;
}

@Override
public FrameData queryFrame(String uid) {
	// TODO Auto-generated method stub
	SqlSession session=sqlSessionFactory.openSession();
	NodeMapper mapper=session.getMapper(NodeMapper.class);
	  FrameData data=  mapper.queryFrame(uid);
	  session.close();
	return data;
}

@Override
public LinkedList<FrameData> isok() {
	// TODO Auto-generated method stub
	SqlSession session=sqlSessionFactory.openSession();
	 NodeMapper mapper =session.getMapper(NodeMapper.class);
	 LinkedList<FrameData> data=mapper.isok();
	 session.close();
	 System.out.println(data);
	return data;
}
}
